package Stringdemo;

import java.util.Scanner;

public class testcode {
    public static void main(String[] args) {
        String rightUsername = "qiaowan";
        String rightKey = "123456";
        Scanner sc = new Scanner(System.in);
        for (int i=0;i<3;i++) {
            System.out.println("请输入用户名");
            String username = sc.next();
            System.out.println("请输入密码");
            String key = sc.next();
            if(username.equals(rightUsername) && key.equals(rightKey)){
                System.out.println("用户登录成功");
                break;
            }
            else {
                System.out.println("用户账户或密码错误,您还剩下"+(2-i)+"次机会。");
            }
        }

    }
}
